
from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select


class MySharePage(BasePage):
    url = "/crm/index.php?m=customer&a=index&by=myshare"
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')
    error_locator =(By.XPATH,"/html/body/div/form/fieldset/div[1]")
    choose_all_locator = (By.ID, 'check_all')  # 全部
    # 批量操作
    batch_operation_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div:nth-child(1) > ul > div > a')
    close_share_locator = (By.ID, 'close_share')  # 取消共享

    def click_choose_all(self):
        """
        点击选择全部
        """
        self.find_element(self.choose_all_locator).click()

    def click_batch_operation(self):
        """
        点击批量操作
        """
        self.find_element(self.batch_operation_locator).click()

    def click_close_share(self):
        """
        点击取消共享
        """
        self.find_element(self.close_share_locator).click()
#返回增删改查后的提示信息
    def get_result_tips(self):
        return self.find_element(self.result_locator).text

#返回弹窗文本信息
    def get_alert_text(self):
        return self.driver.switch_to.alert.text

#返回报错弹窗文本信息
    def get_error_text(self):
        return self.find_element(self.error_locator).text

